package org.noip.milhous.hierarchy;

public class Visulize
{

	private static int VID = 0;

	public static int getID()
		{
			VID++;
			return VID;
		}

	public static final String HEADER = "digraph simple_hierarchy {\n";

	public static final String TAIL = "}";

	public static Integer childDot(StringBuffer stringBuffer, Integer parentid, Object child)
		{
			Integer id = getID();
			if (child != null)
				{
					stringBuffer.append(id + "[ shape= box label =\"" + child.toString().replace("\n", "\\n").replace("\"", "\\\"") + "\"]\n");
					stringBuffer.append(parentid + "->" + id + "\n");
				}
			return id;
		}

	public static Integer rootDot(StringBuffer stringBuffer, Object child)
		{
			Integer id = getID();
			stringBuffer.append(id + "[ shape= box label =\"" + child.toString().replace("\n", "\\n").replace("\"", "\\\"") + "\"]\n");
			return id;
		}

	public static String wrapDot(StringBuffer sb)
		{
			return HEADER + sb.toString() + TAIL;
		}

}
